package com.sskj.motherboard.config;

import com.sskj.common.constant.RabbitMQConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class RabbitMQConfig {

    @Bean
    public Queue iotQueue() {
        return new Queue(RabbitMQConstant.IOT_QUEUE, true);
    }

    @Bean
    public DirectExchange iotExchange() {
        return new DirectExchange(RabbitMQConstant.IOT_EXCHANGE, true, false);
    }

    @Bean
    public Binding iotBinding() {
        return BindingBuilder.bind(iotQueue()).to(iotExchange()).with(RabbitMQConstant.IOT_ROUTEING_KEY);
    }
}
